package com.cskaoyan.dbutils.rsh;

import com.cskaoyan.connectionpool.opensource.DruidUtils;
import com.cskaoyan.dbutils.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/08/29 11:10
 *
 * @author ciggar
 */
public class BeanListHandlerDemo {

    public static void main(String[] args) throws SQLException {

        // 1. 获取一个QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        // 2. 执行SQL语句
        List<User> userList = queryRunner.query("select * from user where id in (?,?,?)",new BeanListHandler<>(User.class),1001,1002,1003);

        // 3. 打印
        System.out.println(userList);

    }

}
